package com.tllq.zhongkang.controller;

import com.tllq.zhongkang.entity.OrderDetail;
import com.tllq.zhongkang.entity.ResultMap;
import com.tllq.zhongkang.service.OrderDetailService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
public class OrderDetailController {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    OrderDetailService orderDetailService;

    @GetMapping("/order-detail")
    public ResultMap findByTime(String startTime,String endTime){
        logger.info("startTime{} endTime{}",startTime,endTime);
        if (StringUtils.isEmpty(startTime) || StringUtils.isEmpty(endTime)){
            return ResultMap.error("参数不能为空");
        }
        List<OrderDetail> orderDetails = orderDetailService.findByTime(startTime, endTime);
        return ResultMap.ok(orderDetails);
    }
}
